Stations

General overview

# install.packages("remotes")
# remotes::install_github("kwb-r/wasserportal", upgrade = "never", force = TRUE)
library(wasserportal)
overview_options <- wasserportal::get_overview_options()
str(overview_options)
#> List of 2
#>  $ surface_water:List of 7
#>   ..$ water_level         : chr "ws"
#>   ..$ flow                : chr "df"
#>   ..$ level               : chr "wt"
#>   ..$ conductivity        : chr "lf"
#>   ..$ ph                  : chr "ph"
#>   ..$ oxygen_concentration: chr "og"
#>   ..$ oxygen_saturation   : chr "os"
#>  $ groundwater  :List of 2
#>   ..$ level  : chr "gws"
#>   ..$ quality: chr "gwq"

system.time(stations <- wasserportal::get_stations())
#> Importing 9 station overviews from Wasserportal Berlin ... ok. (10.10s)
#>    user  system elapsed 
#>   0.056   0.009  10.408

str(stations)
#> List of 3
#>  $ overview_list:List of 9
#>   ..$ surface_water.water_level         : tibble[,9] [70 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: int [1:70] 5865900 5827103 5865300 5819900 5864801 5861101 5800107 5800317 5867401 5800301 ...
#>   .. ..$ Messstellenname  : chr [1:70] "Allee der Kosmonauten" "Allendestraße" "Am Bahndamm" "Am Freibad" ...
#>   .. ..$ Gewaesser        : chr [1:70] "M.-H.-Grenzgr." "Müggelspree" "Wuhle" "Tegeler Fließ" ...
#>   .. ..$ Betreiber        : chr [1:70] "SenUVK" "SenUVK" "SenUVK" "SenUVK" ...
#>   .. ..$ Datum            : chr [1:70] "30.03.2021 05:45" "30.03.2021 05:30" "29.03.2021 23:30" "30.03.2021 05:45" ...
#>   .. ..$ Wasserstand      : int [1:70] 5 50 94 97 4 32 67 73 44 74 ...
#>   .. ..$ Einheit          : chr [1:70] "cm" "cm" "cm" "cm" ...
#>   .. ..$ Ganglinien       : logi [1:70] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:70] "niedrig" "niedrig" "niedrig" "normal" ...
#>   ..$ surface_water.flow                : tibble[,9] [16 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: int [1:16] 5827103 5865300 5864801 5867401 5867900 5827101 5870100 5826701 5862811 5827700 ...
#>   .. ..$ Messstellenname  : chr [1:16] "Allendestraße" "Am Bahndamm" "Am Kienberg" "Bürgerpark" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Müggelspree" "Wuhle" "Hellersdorfer Graben" "Panke" ...
#>   .. ..$ Betreiber        : chr [1:16] "SenUVK" "SenUVK" "SenUVK" "SenUVK" ...
#>   .. ..$ Datum            : chr [1:16] "30.03.2021 05:30" "29.03.2021 23:30" "30.03.2021 04:00" "30.03.2021 02:00" ...
#>   .. ..$ Durchfluss       : num [1:16] 9.56 0.157 0.004 1.63 0.228 10.2 6.16 7 8.97 27.4 ...
#>   .. ..$ Einheit          : chr [1:16] "m³/s" "m³/s" "m³/s" "m³/s" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] "normal" "niedrig" "keine" "normal" ...
#>   ..$ surface_water.level               : tibble[,9] [60 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:60] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:60] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:60] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:60] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:60] "07.10.2020 11:00" "07.10.2020 10:00" "07.10.2020 10:00" "06.10.2020 11:00" ...
#>   .. ..$ Wassertemperatur : chr [1:60] "15.73" "15.14" "14.92" "15.31" ...
#>   .. ..$ Einheit          : chr [1:60] "°C" "°C" "°C" "°C" ...
#>   .. ..$ Ganglinie        : logi [1:60] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:60] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#>   ..$ surface_water.conductivity        : tibble[,9] [16 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "07.10.2020 11:00" "07.10.2020 10:00" "07.10.2020 10:00" "06.10.2020 11:00" ...
#>   .. ..$ Leitfaehigkeit   : chr [1:16] "936" "834" "832" "839" ...
#>   .. ..$ Einheit          : chr [1:16] "µS/cm" "µS/cm" "µS/cm" "µS/cm" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#>   ..$ surface_water.ph                  : tibble[,8] [16 × 8] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "07.10.2020 11:00" "07.10.2020 10:00" "07.10.2020 10:00" "06.10.2020 11:00" ...
#>   .. ..$ pHWert           : chr [1:16] "7.00" "7.32" "7.86" "7.32" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#>   ..$ surface_water.oxygen_concentration: tibble[,9] [16 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "07.10.2020 11:00" "07.10.2020 10:00" "07.10.2020 10:00" "06.10.2020 11:00" ...
#>   .. ..$ Sauerstoffgehalt : chr [1:16] "7.13" "6.26" "5.94" "6.06" ...
#>   .. ..$ Einheit          : chr [1:16] "mg/l" "mg/l" "mg/l" "mg/l" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#>   ..$ surface_water.oxygen_saturation   : tibble[,9] [16 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: chr [1:16] "601" "151" "153" "509" ...
#>   .. ..$ Messstellenname  : chr [1:16] "MPS Berlin-Spandauer-Schifffahrtskanal" "MPS Caprivibrücke" "MPS Charlottenburg" "MPS Landwehrkanal" ...
#>   .. ..$ Gewaesser        : chr [1:16] "Berlin-Spandauer-Schifffahrtskanal" "Spree" "Spree" "Landwehrkanal" ...
#>   .. ..$ Betreiber        : chr [1:16] "Land Berlin" "Land Berlin" "Land Berlin" "Land Berlin" ...
#>   .. ..$ Datum            : chr [1:16] "07.10.2020 11:00" "07.10.2020 10:00" "07.10.2020 10:00" "06.10.2020 11:00" ...
#>   .. ..$ Parameterwert    : chr [1:16] "72.01" "62.44" "58.97" "60.66" ...
#>   .. ..$ Einheit          : chr [1:16] "%" "%" "%" "%" ...
#>   .. ..$ Ganglinie        : logi [1:16] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:16] "inaktiv" "inaktiv" "inaktiv" "inaktiv" ...
#>   ..$ groundwater.level                 : tibble[,10] [871 × 10] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer        : int [1:871] 1 2 3 4 9 21 24 25 26 30 ...
#>   .. ..$ Bezirk                   : chr [1:871] "Reinickendorf" "Reinickendorf" "Reinickendorf" "Reinickendorf" ...
#>   .. ..$ Auspraegung              : chr [1:871] "GW-Stand" "GW-Stand" "GW-Stand" "GW-Stand" ...
#>   .. ..$ Grundwasserleiter        : chr [1:871] "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" ...
#>   .. ..$ Grundwasserspannung      : chr [1:871] "gespannt" "ungespannt" "gespannt" "ungespannt" ...
#>   .. ..$ Datum                    : chr [1:871] "04.03.2021" "03.03.2021" "04.02.2021" "04.03.2021" ...
#>   .. ..$ Grundwasserstand_m_ue_NHN: num [1:871] 33.7 35.3 33.5 32.5 37.2 ...
#>   .. ..$ Flur_abstand_m_u_GOK     : chr [1:871] "keine Angabe" "2.34" "keine Angabe" "7.42" ...
#>   .. ..$ Ganglinie                : logi [1:871] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation           : chr [1:871] "extrem niedrig" "normal" "sehr niedrig" "sehr niedrig" ...
#>   ..$ groundwater.quality               : tibble[,9] [190 × 9] (S3: tbl_df/tbl/data.frame)
#>   .. ..$ Messstellennummer: int [1:190] 149 1359 3354 4061 4105 4233 4304 4521 4611 4612 ...
#>   .. ..$ Bezirk           : chr [1:190] "Mitte" "Charlottenburg-Wilmersdorf" "Treptow-Köpenick" "Spandau" ...
#>   .. ..$ Auspraegung      : chr [1:190] "GW-Stand + GW-Güte" "GW-Stand + GW-Güte" "GW-Stand, tagesaktuell + GW-Güte" "GW-Stand, tagesaktuell + GW-Güte" ...
#>   .. ..$ Grundwasserleiter: chr [1:190] "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" "Hauptgrundwasserleiter (GWL 1.3 + 2)" ...
#>   .. ..$ Datum            : chr [1:190] "14.11.2019" "04.12.2019" "07.10.2019" "27.11.2019" ...
#>   .. ..$ Parameterwert    : num [1:190] 12.2 12.3 10 11.3 12.9 12.7 12.2 11.4 12.3 12.8 ...
#>   .. ..$ Einheit          : chr [1:190] "grd C" "grd C" "grd C" "grd C" ...
#>   .. ..$ Ganglinie        : logi [1:190] NA NA NA NA NA NA ...
#>   .. ..$ Klassifikation   : chr [1:190] "keine" "keine" "keine" "keine" ...
#>  $ overview_df  :Classes 'data.table' and 'data.frame':  1271 obs. of  26 variables:
#>   ..$ key                      : chr [1:1271] "surface_water.water_level" "surface_water.water_level" "surface_water.water_level" "surface_water.water_level" ...
#>   ..$ Messstellennummer        : chr [1:1271] "5865900" "5827103" "5865300" "5819900" ...
#>   ..$ Messstellenname          : chr [1:1271] "Allee der Kosmonauten" "Allendestraße" "Am Bahndamm" "Am Freibad" ...
#>   ..$ Gewaesser                : chr [1:1271] "M.-H.-Grenzgr." "Müggelspree" "Wuhle" "Tegeler Fließ" ...
#>   ..$ Betreiber                : chr [1:1271] "SenUVK" "SenUVK" "SenUVK" "SenUVK" ...
#>   ..$ Datum                    : chr [1:1271] "30.03.2021 05:45" "30.03.2021 05:30" "29.03.2021 23:30" "30.03.2021 05:45" ...
#>   ..$ Wasserstand              : int [1:1271] 5 50 94 97 4 32 67 73 44 74 ...
#>   ..$ Einheit                  : chr [1:1271] "cm" "cm" "cm" "cm" ...
#>   ..$ Ganglinien               : logi [1:1271] NA NA NA NA NA NA ...
#>   ..$ Klassifikation           : chr [1:1271] "niedrig" "niedrig" "niedrig" "normal" ...
#>   ..$ Durchfluss               : num [1:1271] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ Ganglinie                : logi [1:1271] NA NA NA NA NA NA ...
#>   ..$ Wassertemperatur         : chr [1:1271] NA NA NA NA ...
#>   ..$ Leitfaehigkeit           : chr [1:1271] NA NA NA NA ...
#>   ..$ pHWert                   : chr [1:1271] NA NA NA NA ...
#>   ..$ Sauerstoffgehalt         : chr [1:1271] NA NA NA NA ...
#>   ..$ Parameterwert            : chr [1:1271] NA NA NA NA ...
#>   ..$ Bezirk                   : chr [1:1271] NA NA NA NA ...
#>   ..$ Auspraegung              : chr [1:1271] NA NA NA NA ...
#>   ..$ Grundwasserleiter        : chr [1:1271] NA NA NA NA ...
#>   ..$ Grundwasserspannung      : chr [1:1271] NA NA NA NA ...
#>   ..$ Grundwasserstand_m_ue_NHN: num [1:1271] NA NA NA NA NA NA NA NA NA NA ...
#>   ..$ Flur_abstand_m_u_GOK     : chr [1:1271] NA NA NA NA ...
#>   ..$ water_body               : chr [1:1271] "surface_water" "surface_water" "surface_water" "surface_water" ...
#>   ..$ variable                 : chr [1:1271] "water_level" "water_level" "water_level" "water_level" ...
#>   ..$ station_type             : chr [1:1271] "ws" "ws" "ws" "ws" ...
#>   ..- attr(*, ".internal.selfref")=<externalptr> 
#>  $ crosstable   : tibble[,11] [996 × 11] (S3: tbl_df/tbl/data.frame)
#>   ..$ Messstellennummer: chr [1:996] "5865900" "5827103" "5865300" "5819900" ...
#>   ..$ Messstellenname  : chr [1:996] "Allee der Kosmonauten" "Allendestraße" "Am Bahndamm" "Am Freibad" ...
#>   ..$ ws               : chr [1:996] "x" "x" "x" "x" ...
#>   ..$ df               : chr [1:996] NA "x" "x" NA ...
#>   ..$ wt               : chr [1:996] NA NA "x" NA ...
#>   ..$ lf               : chr [1:996] NA NA NA NA ...
#>   ..$ ph               : chr [1:996] NA NA NA NA ...
#>   ..$ og               : chr [1:996] NA NA NA NA ...
#>   ..$ os               : chr [1:996] NA NA NA NA ...
#>   ..$ gws              : chr [1:996] NA NA NA NA ...
#>   ..$ gwq              : chr [1:996] NA NA NA NA ...

jsonlite::write_json(stations$crosstable, 
                     path = "stations_crosstable.json",
                     pretty = TRUE)
DT::datatable(stations$crosstable, filter = "top", caption = "Data availabilty 
              per monitoring station")

The crosstable data for checking data availabilty of the monitoring stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_crosstable.json

GW level

Master data

Overview data of GW level stations can be requested as shown below:


DT::datatable(stations$overview_list$groundwater.level, filter = "top")

Master data of GW level stations can be requested as shown below:

stations_gwl_master <- wasserportal::get_wasserportal_masters_data(
  station_ids = stations$overview_list$groundwater.level$Messstellennummer
)
#> Importing 871 station metadata from Wasserportal Berlin ... ok. (8.32s)

jsonlite::write_json(stations_gwl_master, 
                     path = "stations_gwl_master.json",
                     pretty = TRUE)

DT::datatable(stations_gwl_master, filter = "top")

The master data of GW level stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_gwl_master.json

Trend Classification

GW level trend classification (provided by SenWeb) is visualized below.

Trend Classification Histogramm

gwl <- stations$overview_list$groundwater.level %>% 
  dplyr::mutate(Datum = as.Date(Datum, format = "%d.%m.%Y"))

levels_ordered <- c("extrem niedrig",
                    "sehr niedrig",
                    "niedrig", 
                    "normal",
                    "hoch",
                    "sehr hoch",
                    "extrem hoch",
                    "keine")

text_low_levels <- c("extrem niedrig", "sehr niedrig", "niedrig")
text_high_levels <- c("hoch", "sehr hoch", "extrem hoch")

gwl$Klassifikation <- forcats::fct_relevel(gwl$Klassifikation, levels_ordered)

gwl_classified_only <- gwl %>% dplyr::filter(Klassifikation != "keine")

percental_share_low_levels <- 100*sum(gwl_classified_only$Klassifikation %in% text_low_levels)/nrow(gwl_classified_only) 

percental_share_high_levels <- 100*sum(gwl_classified_only$Klassifikation %in% text_high_levels)/nrow(gwl_classified_only) 

title_text <- sprintf("GW level classification (n = %d out of %d have 'classification' data)", nrow(gwl_classified_only), nrow(gwl))

g1 <- gwl_classified_only %>% 
  dplyr::count(Klassifikation, Grundwasserspannung) %>% 
  dplyr::mutate(percental_share = 100 * n / nrow(gwl)) %>% 
  ggplot2::ggplot(ggplot2::aes_string(x = "Klassifikation",
                                      y = "percental_share",
                                      fill = "Grundwasserspannung")) +
  ggplot2::geom_bar(stat = "identity") + 
  ggplot2::labs(title = title_text,
                x = "Classification",
                y = "Percental share (%)") +
  ggplot2::theme_bw()

plotly::ggplotly(g1)

61.07 percent of all considered 804 GW level monitoring stations containing classification data (out of 871 provided by SenWeb) indicate below normal (extrem niedrig, sehr niedrig, niedrig) GW levels. However, only 61.07 percent are indicate above normal (hoch, sehr hoch, extrem hoch) GW levels.

Trend Classification Map
level_colors <- data.frame(Klassifikation = levels_ordered, 
                           classi_color = c("darkred", 
                                            "red", 
                                            "orange", 
                                            "green",
                                            "lightblue", 
                                            "blue", 
                                            "darkblue",
                                            "grey"))

gwl_classified_only_with_coords <- gwl_classified_only %>% 
  dplyr::mutate(Messstellennummer = as.character(Messstellennummer),
                label_text = paste("Messstellennummer:", 
                                    Messstellennummer, 
                                    "; ",
                                    "Grundwasserspannung:", 
                                    Grundwasserspannung, 
                                    ";",
                                    "Klassifikation:", 
                                    Klassifikation,
                                   ";",
                                   "Datum:",
                                   Datum
                                   )) %>% 
  dplyr::left_join(stations_gwl_master %>%
                     dplyr::select("Nummer", 
                                   "Rechtswert_UTM_33_N",
                                   "Hochwert_UTM_33_N") %>% 
                     dplyr::rename(Messstellennummer = "Nummer"),
                   by = "Messstellennummer") %>% 
  dplyr::left_join(level_colors, by = "Klassifikation") %>% 
  sf::st_as_sf(coords = c("Rechtswert_UTM_33_N", "Hochwert_UTM_33_N"),
               crs = 25833) %>% 
  sf::st_transform(crs = 4326)



  gwlmap <- gwl_classified_only_with_coords %>% 
  leaflet::leaflet() %>%
  leaflet::addTiles() %>% 
  leaflet::addProviderTiles(leaflet::providers$CartoDB.Positron) %>% 
  leaflet::addCircles(color = ~classi_color,
                      label = ~label_text) %>% 
  leaflet::addLegend(position = "topright",
                     colors = level_colors$classi_color,
                     labels = level_colors$Klassifikation,
                     title = sprintf("Classification (latest data: %s)",
                                     max(gwl_classified_only_with_coords$Datum))
                     )
  
  htmlwidgets::saveWidget(gwlmap, 
                          "./map_gwl-trend.html", 
                          title = "GW level trend")
  
  gwlmap

GW level trend plot is also available on a full html page here: https://kwb-r.github.io/wasserportal/map_gwl-trend.html

Download and Plotting One Station

for total period available.

station_gwl <- stations$overview_list$groundwater.level[1,]
ncols <- 2:ncol(station_gwl)

gw_level <- wasserportal::read_wasserportal_raw_gw(
  station = station_gwl$Messstellennummer, 
  stype = "gwl") %>% 
dplyr::mutate(Label = sprintf("%s (%s)", Parameter, Einheit))
head(gw_level)
#> # A tibble: 6 x 6
#>   Messstellennummer Datum      Parameter Einheit  Messwert Label              
#>               <int> <date>     <chr>     <chr>       <dbl> <chr>              
#> 1                 1 1953-11-01 GW-Stand  m ü. NHN     34.8 GW-Stand (m ü. NHN)
#> 2                 1 1953-11-15 GW-Stand  m ü. NHN     34.8 GW-Stand (m ü. NHN)
#> 3                 1 1953-12-01 GW-Stand  m ü. NHN     34.7 GW-Stand (m ü. NHN)
#> 4                 1 1953-12-15 GW-Stand  m ü. NHN     34.7 GW-Stand (m ü. NHN)
#> 5                 1 1954-01-01 GW-Stand  m ü. NHN     34.7 GW-Stand (m ü. NHN)
#> 6                 1 1954-01-15 GW-Stand  m ü. NHN     34.7 GW-Stand (m ü. NHN)

g <- gw_level %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", y = "Messwert", col = "Label")) +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()


title_subtitle <- paste0(paste0(names(station_gwl)[1], ": ", 
                             station_gwl[1], 
                             collapse =", "),
       "<br>",
       "<sup>",
       paste0(names(station_gwl)[ncols], ": ",
              station_gwl[ncols], 
              collapse =", "),
       "</sup>")


plotly::ggplotly(g) %>%
  plotly::layout(title = list(text = title_subtitle))

Download and Plotting Multiple Stations

gw_level_multi <- data.table::rbindlist(
  lapply(stations$overview_list$groundwater.level$Messstellennummer[1:5], 
                     function(id) {
                       wasserportal::read_wasserportal_raw_gw(
                         station = id, stype = "gwl")
                     }))


jsonlite::write_json(gw_level_multi,
                     path = "stations_gwl_data.json",
                     pretty = TRUE)


# Plot 10 GW level
selected_stations <- stations$overview_list$groundwater.level$Messstellennummer[1:10]

g <- gw_level_multi %>% 
dplyr::filter(Messstellennummer %in% selected_stations) %>% 
dplyr::mutate(Messstellennummer = as.character(Messstellennummer)) %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", 
                                    y = "Messwert", 
                                    col = "Messstellennummer")) +
ggplot2::labs(title = "GW level (m above NN)") +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()

plotly::ggplotly(g)

The data of all GW level stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_gwl_data.json

GW quality

Overview data of GW level stations can be requested as shown below:

stations_gwq <- wasserportal::get_wasserportal_stations_table(
  type = overview_options$groundwater$quality
  )

DT::datatable(stations_gwq, filter = "top")

Master data of GW quality stations can be requested as shown below:

stations_gwq_master <- wasserportal::get_wasserportal_masters_data(
  station_ids = stations_gwq$Messstellennummer
)
#> Importing 190 station metadata from Wasserportal Berlin ... ok. (1.85s)

jsonlite::write_json(stations_gwq_master, 
                     path = "stations_gwq_master.json",
                     pretty = TRUE)

The master data of GW quality stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_gwq_master.json

GW Quality: Download and Plotting One Station

station_gwq <- stations$overview_list$groundwater.quality[1,]
ncols <- 2:ncol(station_gwq)

gw_quality <- wasserportal::read_wasserportal_raw_gw(
  station = station_gwq$Messstellennummer, 
  stype = "gwq")
head(gw_quality)
#> # A tibble: 6 x 5
#>   Messstellennummer Datum      Parameter                  Einheit      Messwert
#>               <int> <date>     <chr>                      <chr>           <dbl>
#> 1               149 2005-05-11 Temperatur (Luft)          grd Celsius      6   
#> 2               149 2005-05-11 pH-Wert (Feld)             ohne Einheit     7.4 
#> 3               149 2005-05-11 Temperatur (Wasser)        grd C           13.4 
#> 4               149 2005-05-11 Leitfähigkeit 25°C vor Ort µS/cm         1005.  
#> 5               149 2005-05-11 Wasserst.(ROK) vor         m                3.21
#> 6               149 2005-05-11 Chlorid                    mg/l            54

unique(gw_quality$Parameter)
#>   [1] "Temperatur (Luft)"                       
#>   [2] "pH-Wert (Feld)"                          
#>   [3] "Temperatur (Wasser)"                     
#>   [4] "Leitfähigkeit 25°C vor Ort"              
#>   [5] "Wasserst.(ROK) vor"                      
#>   [6] "Chlorid"                                 
#>   [7] "Fluorid"                                 
#>   [8] "Hydrogenkarbonat"                        
#>   [9] "Nitrit (N)"                              
#>  [10] "Nitrat (N)"                              
#>  [11] "Orhto-Phosphat (P)"                      
#>  [12] "Sulfid"                                  
#>  [13] "Sulfat"                                  
#>  [14] "Cyanide (ges.)"                          
#>  [15] "Bromid"                                  
#>  [16] "Nitrit"                                  
#>  [17] "Nitrat"                                  
#>  [18] "Ortho-Phosphat"                          
#>  [19] "Ammonium (N)"                            
#>  [20] "Eisen-2"                                 
#>  [21] "Eisen (ges.)"                            
#>  [22] "Kalium"                                  
#>  [23] "Kalzium"                                 
#>  [24] "Magnesium"                               
#>  [25] "Natrium"                                 
#>  [26] "Mangan"                                  
#>  [27] "Ammonium"                                
#>  [28] "Leitfähigkeit /Lab. bei 25°C"            
#>  [29] "UV-Adsorption (254)"                     
#>  [30] "CSV (KMNO4)"                             
#>  [31] "Basenkap. bis 8.2"                       
#>  [32] "Säure-Kap. bis 4.3"                      
#>  [33] "Kohlenstoff (organ.)"                    
#>  [34] "pH-Wert /Lab."                           
#>  [35] "Gesamthärte"                             
#>  [36] "Karbonathärte"                           
#>  [37] "AOX"                                     
#>  [38] "Phenolindex (ges.)"                      
#>  [39] "LHKW (Summe)"                            
#>  [40] "BTXE (Summe)"                            
#>  [41] "Arsen"                                   
#>  [42] "Barium"                                  
#>  [43] "Blei"                                    
#>  [44] "Bor"                                     
#>  [45] "Cadmium"                                 
#>  [46] "Chrom"                                   
#>  [47] "Kupfer"                                  
#>  [48] "Aluminium-gelöst"                        
#>  [49] "Nickel"                                  
#>  [50] "Quecksilber"                             
#>  [51] "Selen"                                   
#>  [52] "Zink"                                    
#>  [53] "Dichlormethan"                           
#>  [54] "Trichlormethan"                          
#>  [55] "Tetrachlormethan"                        
#>  [56] "1,2-Dichlorethan"                        
#>  [57] "cis-1,2-Dichloreth."                     
#>  [58] "1,1,1-Tri-Cl-Ethan"                      
#>  [59] "Trichlorethen"                           
#>  [60] "Tetrachlorethen"                         
#>  [61] "Vinylchlorid"                            
#>  [62] "trans-1,2-Dichloret."                    
#>  [63] "Benzen"                                  
#>  [64] "Ethylbenzen"                             
#>  [65] "Toluen"                                  
#>  [66] "Xylen (meta/para)"                       
#>  [67] "Xylen (ortho)"                           
#>  [68] "Cumol"                                   
#>  [69] "Naphtalin"                               
#>  [70] "Acenaphthylen"                           
#>  [71] "Acenaphthen"                             
#>  [72] "Fluoren"                                 
#>  [73] "Phenanthren"                             
#>  [74] "Anthracen"                               
#>  [75] "Fluoranthen"                             
#>  [76] "Pyren"                                   
#>  [77] "Benz-a-Anthracen"                        
#>  [78] "Chrysen"                                 
#>  [79] "Benz-b-Fluoranthen"                      
#>  [80] "Benz-k-Fluoranthen"                      
#>  [81] "Benz-a-Pyren"                            
#>  [82] "Dibenz-a,h-Anthracen"                    
#>  [83] "Benz-g,h,i-Perylen"                      
#>  [84] "Indeno-1,2,3-cd-Pyr."                    
#>  [85] "DDT (para,para)"                         
#>  [86] "DDE (para,para)"                         
#>  [87] "DDD (para,para)"                         
#>  [88] "DDT (ortho,para)"                        
#>  [89] "DDE (orhto,para)"                        
#>  [90] "DDD (ortho,para)"                        
#>  [91] "epsilon-HCH"                             
#>  [92] "DDA (para,para)"                         
#>  [93] "alpha-Endosulfan"                        
#>  [94] "beta-Endosulfan"                         
#>  [95] "alpha-HCH"                               
#>  [96] "beta-HCH"                                
#>  [97] "delta-HCH"                               
#>  [98] "Lindan"                                  
#>  [99] "DDMU (para,para)"                        
#> [100] "Endosulfansulfat"                        
#> [101] "Bentazon"                                
#> [102] "Trifuralin"                              
#> [103] "Atrazin"                                 
#> [104] "Simazin"                                 
#> [105] "Desethylsimazin"                         
#> [106] "Dimethoate"                              
#> [107] "Parathion-Ethyl"                         
#> [108] "Isoproturon"                             
#> [109] "Diuron"                                  
#> [110] "Lenacil"                                 
#> [111] "24_D"                                    
#> [112] "Dichlorprop"                             
#> [113] "MCPA"                                    
#> [114] "Chlorflurenol"                           
#> [115] "Mecoprop"                                
#> [116] "Dicamba"                                 
#> [117] "Oxydemeton-Methyl"                       
#> [118] "Propoxur"                                
#> [119] "Pirimicarb"                              
#> [120] "Deltamethrin"                            
#> [121] "Dichlofluanid"                           
#> [122] "Iprodion"                                
#> [123] "Propyzamid"                              
#> [124] "Chlorpyrifos"                            
#> [125] "EDTA"                                    
#> [126] "NTA"                                     
#> [127] "Bezafibrat"                              
#> [128] "Gemfibrozil"                             
#> [129] "Indomethacin"                            
#> [130] "Clofibrinsäure"                          
#> [131] "Diclofenac"                              
#> [132] "Ketoprofen"                              
#> [133] "Ibuprofen"                               
#> [134] "Naproxen"                                
#> [135] "Summe Na+Cl"                             
#> [136] "Wasserst.(ROK) nach"                     
#> [137] "Entnahmeteufe (ROK)"                     
#> [138] "Förderrate"                              
#> [139] "Redox Pumpbeginn"                        
#> [140] "O2-Gehalt Pumpbeg."                      
#> [141] "Redox Pumpende"                          
#> [142] "pH Pumpende"                             
#> [143] "O2-Gehalt Pumpende"                      
#> [144] "Parathion-Methyl"                        
#> [145] "Vanadium"                                
#> [146] "Molybdän"                                
#> [147] "Thallium"                                
#> [148] "Uran"                                    
#> [149] "Enterokokken"                            
#> [150] "Desisopropylatrazin"                     
#> [151] "Aluminium"                               
#> [152] "Phenole, wasserdampfflüchtig"            
#> [153] "Desethylatrazin"                         
#> [154] "Terbutryn"                               
#> [155] "Desethylterbutylazin"                    
#> [156] "Glyphosat"                               
#> [157] "AMPA"                                    
#> [158] "2,6-Dichlorbenzamid"                     
#> [159] "Carbamazepin"                            
#> [160] "Dimethachlor-Metabolit CGA 369873"       
#> [161] "Dimethachlor-Metabolit CGA 373464"       
#> [162] "Dimethachlor-Sulfonsäure CGA 354742"     
#> [163] "Dimethachlorsäure CGA 50266"             
#> [164] "Metazachlor-Sulfonsäure BH 479-8"        
#> [165] "Metazachlor-Oxalsäure BH 479-4"          
#> [166] "Methyl-Desphenylchloridazon (Metabolit B"
#> [167] "S-Metolachlor Metabolit NOA 413173"      
#> [168] "S-Metolachlor-Metabolit CGA 357704"      
#> [169] "S-Metolachlor-Metabolit CGA 368208"      
#> [170] "S-Metolachlor-Sulfonsäure CGA 380168 / C"
#> [171] "S-Metolachlorsäure CGA 351916 / CGA 5120"
#> [172] "Ionenbilanz (Labor)"                     
#> [173] "Propyphenazon"                           
#> [174] "Phenazon"                                
#> [175] "1-Acetyl-1-methyl-2-dimethyl-oxamoyl-2-p"
#> [176] "Methylhexanamin"                         
#> [177] "1,2-Dihydro-1,5-dimethylpyrazol-3-on-CAS"
#> [178] "MTBE"                                    
#> [179] "Ethyl-t-butylether"                      
#> [180] "1,2,4-Triazol CGA 71019"                 
#> [181] "Azoxystrobin-Carbonsäure (R234886, ICIA5"
#> [182] "Diflufenican AE B107137"                 
#> [183] "Dimethenamid-Sulfonsäure (M656PH027, M27"
#> [184] "Flufenacet-Sulfonsäure (AE 0841914, M2)" 
#> [185] "Metalaxyl-Carbonsäure (NOA 409045) (Race"
#> [186] "Metazachlor BH 479-11"                   
#> [187] "Metazachlor BH 479-9"                    
#> [188] "Propiconazol NOA436613"                  
#> [189] "Thiacloprid-Sulfonsäure (M30)"           
#> [190] "Trifloxystrobin-Dicarbonsäure NOA 413161"

g <- gw_quality %>%  
dplyr::filter(Parameter == "Sulfat") %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", y = "Messwert", col = "Parameter")) +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()


title_subtitle <- paste0(paste0(names(station_gwq)[1], ": ", 
                             station_gwq[1], 
                             collapse =", "),
       "<br>",
       "<sup>",
       paste0(names(station_gwq)[ncols], ": ",
              station_gwq[ncols], 
              collapse =", "),
       "</sup>")


plotly::ggplotly(g) %>%
  plotly::layout(title = list(text = title_subtitle))

GW Quality: Download and Plotting Multiple Stations

gw_quality_multi <- data.table::rbindlist(
  lapply(stations$overview_list$groundwater.quality$Messstellennummer, 
                     function(id) {
                       wasserportal::read_wasserportal_raw_gw(
                         station = id, stype = "gwq")
                     }))


jsonlite::write_json(gw_quality_multi,
                     path = "stations_gwq_data.json",
                     pretty = TRUE)


# Plot 10 GW quality 
selected_stations <- stations$overview_list$groundwater.quality$Messstellennummer[1:10]

g <- gw_quality_multi %>% 
dplyr::filter(Messstellennummer %in% selected_stations) %>% 
dplyr::mutate(Messstellennummer = as.character(Messstellennummer)) %>% 
dplyr::filter(Parameter == "Sulfat") %>% 
ggplot2::ggplot(ggplot2::aes_string(x = "Datum", 
                                    y = "Messwert", 
                                    col = "Messstellennummer")) +
ggplot2::labs(title = "GW quality (Sulfat)") +
ggplot2::geom_line() +
ggplot2::geom_point() +
ggplot2::theme_bw()

plotly::ggplotly(g)

The data of all GW quality stations is also available in JSON format here: https://kwb-r.github.io/wasserportal/stations_gwq_data.json